import java.util.Arrays;

public class HashBuck {
    static class Node{
        public int key;
        public int val;
        public Node next;

        public Node(int key, int val) {
            this.key = key;
            this.val = val;
        }
    }
    public Node[] arr=new Node[10];
    public int usedSize;
    public static final double loadFactor=0.75f;

    public void push(int key,int val){
        int index=key%arr.length;
        Node cur=arr[index];
        while(cur!=null){
            if(cur.key==key){
                cur.val=val;
                return;
            }
            cur=cur.next;
        }
        Node node=new Node(key, val);
        node.next=arr[index];
        arr[index]=node;
        usedSize++;
        if(doLoadFactor()>=loadFactor){
            resize();
        }
    }

    private void resize(){
        Node[] newArray=new Node[2*arr.length];
        for(int i=0;i<arr.length;i++){
            Node cur=arr[i];
            while(cur!=null){
                int newIndex=cur.key%newArray.length;
                Node curN=cur.next;
                cur.next=newArray[newIndex];
                newArray[newIndex]=cur;
                cur=curN;
            }
        }
        arr=newArray;
    }
    private double doLoadFactor(){
        return usedSize*1.0/arr.length;
    }
    public int getVal(int key){
        int index=key%arr.length;
        Node cur=arr[index];
        while(cur!=null&&cur.key!=key){
            cur=cur.next;
        }
        if(cur.key==key){
            return cur.val;
        }else {
            return -1;
        }
    }
}
